<?php
global $current_user, $app_abbr, $gmap_active, $cp_options;

// make sure google maps has a valid address field before showing tab
$custom_fields = get_post_custom(); 
if ( !empty($custom_fields[$app_abbr.'_zipcode']) || !empty($custom_fields[$app_abbr.'_country']) || 
	!empty($custom_fields[$app_abbr.'_state']) || !empty($custom_fields[$app_abbr.'_city']) || 
	!empty($custom_fields[$app_abbr.'_street']) ) {
	$gmap_active = true; 
}
	$gmap_active = true; 
?>

<!-- right sidebar -->
<div class="content_right">
	<div class="tabprice">

		<ul class="tabnavig">
                    
			<?php if ( $gmap_active ) { ?>
                    <li><a href="#priceblock1"><span class="big"><?php _e( 'Map', APP_TD ); ?></span></a></li>
                    <?php } ?>
			<li><a href="#priceblock2"><span class="big"><?php _e( 'Thông tin', APP_TD ); ?></span></a></li>
		</ul>


		<?php if ( $gmap_active ) { ?>

			<!-- tab 1 -->
			<div id="priceblock1">

				<div class="clr"></div>

				<div class="singletab">

					<?php get_template_part( 'includes/sidebar', 'gmap' ); ?>

				</div><!-- /singletab -->

			</div>

		<?php } ?>


		<!-- tab 2 -->
		<div id="priceblock2">
                    <div class="clr"></div>

			<div class="postertab">

				<div class="priceblocksmall dotted">

					<p class="member-title">Thông Tin Cửa Hàng</p>

					<div id="userphoto">
						<p class='image-thumb'>
                <?php 
                    //get avatar here
                    global $current_user;
                    $avatarUrl = getUserAvatar($current_user->ID);
                ?>
                                                    <img alt="" src="<?php echo $avatarUrl; ?>" class="avatar avatar-64 photo avatar-default" height="64" width="64">
                                                
                                                
                                                </p>
					</div>

					<ul class="member">

						<li><span>Điểm:</span>100
<!--							<a href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>"><?php the_author_meta('display_name'); ?></a>-->
						</li>

						<li><span>Sản phẩm</span>123
                                                </li>
                                                
                                                <li><span>Bài viết</span>400
                                                </li>

					</ul>

					<?php cp_author_info( 'sidebar-ad' ); ?>

					<div class="pad5"></div>

					<div class="clr"></div>

				</div>

				<div class="pad5"></div>

				<h3><?php _e( 'Các sản phẩm khác', APP_TD ); ?> <?php the_author_meta('display_name'); ?></h3>

				<div class="pad5"></div>

				<ul>

				<?php $other_items = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => APP_POST_TYPE, 'post_status' => 'publish', 'author' => get_the_author_meta('ID'), 'orderby' => 'rand', 'post__not_in' => array( $post->ID ) ) ); ?>

				<?php if ( $other_items->have_posts() ) : ?>

					<?php while ( $other_items->have_posts() ) : $other_items->the_post(); ?>

						<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

					<?php endwhile; ?>

				<?php else: ?>

					<li><?php _e( 'No other ads by this poster found.', APP_TD ); ?></li>

				<?php endif; ?>

				<?php wp_reset_postdata(); ?>

				</ul>

				<div class="pad5"></div>

				<a href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>" class="btn"><span><?php _e( 'Latest items listed by', APP_TD ); ?> <?php the_author_meta('display_name'); ?> &raquo;</span></a>

			</div><!-- /singletab -->


<!--			<div class="clr"></div>

			<div class="singletab">

			<?php if ( ( $cp_options->ad_inquiry_form && is_user_logged_in() ) || ! $cp_options->ad_inquiry_form ) {

				get_template_part( 'includes/sidebar', 'contact' );

			} else {
			?>
				<div class="pad25"></div>
				<p class="contact_msg center"><strong><?php _e( 'You must be logged in to inquire about this ad.', APP_TD ); ?></strong></p>
				<div class="pad100"></div>
			<?php } ?>

			</div> /singletab -->

		</div><!-- /priceblock2 -->
	</div><!-- /tabprice -->


	<?php appthemes_before_sidebar_widgets(); ?>

	<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('sidebar_listing') ) : else : ?>

	<!-- no dynamic sidebar so don't do anything -->

	<?php endif; ?>

	<?php appthemes_after_sidebar_widgets(); ?>


</div><!-- /content_right -->
